package cn.dlc.com.config;

import cn.dlc.com.utils.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;
import java.security.PrivateKey;
import java.security.PublicKey;

/**
 * @author deng
 * @date 2021/6/25 10:32
 **/
@Data
@ConfigurationProperties(prefix = "rsa.key")
public class RsaPropertiesConfig {

    private String publicKeyPath;
    private String privateKeyPath;

    private PublicKey publicKey;
    private PrivateKey privateKey;


    // 初始化之后被调用
    @PostConstruct
    public void createRsaKey() throws Exception{
        privateKey = RsaUtils.getPrivateKey(privateKeyPath);
        publicKey = RsaUtils.getPublicKey(publicKeyPath);

    }
}
